# switch
# 表示结果可选项
# 使用方式
switch(expr,answer1=code1,answer2=code2,...)


# require(stats)
centre <- function(x, type) {
  switch(type,
         mean = mean(x),
         median = median(x),
         trimmed = mean(x, trim = .1))
}
x <- rcauchy(10)
centre(x, "mean")
centre(x, "median")
centre(x, "trimmed")


# 练习，模仿以上方式，构造样本方差、样本均值、样本峰度、样本偏度的函数
# 并检验成功